package com.example.exception;


import com.example.utils.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@ControllerAdvice(basePackages = "com.example.demo2secur.demos.controller")
public class GlobalExceptionHandler {

    @ExceptionHandler(CustomException.class)
    @ResponseBody//返回json串
    public R customError(CustomException e) {
        return R.error(Integer.valueOf(e.getCode()), e.getMsg());
    }
}
